package com.sun.designpatternsdemo.factory.bean.cxgc

import android.util.Log

/**
 * 版权：xx公司 版权所有
 * @author sun
 * 版本：1.0
 * 创建日期：2021/6/29 10:56
 * 描述：
 *
 */
class XianRoujiamoTeSeStrore(val factory: XianSimpleRoujiaMoTeSeFacktory) : RouJiaMoStore() {

    override fun sellRoujiaMo(type: String): RoujiaMo {
        return factory.createRoujiaMo(type)
            .apply {
                prepare(XianRoujiaMoYLFactory())
                fire()
                pack()
            }
    }
}

class XianSimpleRoujiaMoTeSeFacktory {
    fun createRoujiaMo(type: String): RoujiaMo {
        return when (type) {
            "suan" -> XianSuanRoujiMo2()
            else -> XianSuanRoujiMo2()
        }
    }
}

class XianRoujiaMoYLFactory : RoujiamoYLFactory {
    override fun createMeet(): Meet = XianFreshMeet()

    override fun createYuanLiao(): YuanLiao = XianTeSeYuanLiao()

}

abstract class RoujiaMo {
    var name: String? = null

    fun prepare(factory: RoujiamoYLFactory) {
        val meet = factory.createMeet()
        val yuanLiao = factory.createYuanLiao()
        Log.e(
            "---RoujiaMo:",
            "使用官方的原料 ---" + name + ": 揉面-剁肉-完成准备工作 yuanLiao:" + meet + "yuanLiao:" + yuanLiao
        )
    }

    fun fire() {
        Log.e("---RoujiaMo:", "$name: 肉夹馍-专用设备-烘烤")
    }

    fun pack() {
        Log.e("---RoujiaMo:", "$name: 肉夹馍-专用袋-包装---end")
    }
}

interface RoujiamoYLFactory {
    //生产肉
    fun createMeet(): Meet

    fun createYuanLiao(): YuanLiao
}

abstract class RouJiaMoStore {
    abstract fun sellRoujiaMo(type: String): RoujiaMo
}

open class Meet()

open class YuanLiao()

class XianSuanRoujiMo2 : RoujiaMo() {
    init {
        name = "西安 酸肉夹馍"
    }
}


data class XianFreshMeet(var meet: String = "西安鲜肉") : Meet() {

}

data class  XianTeSeYuanLiao(var yuanliao: String = "西安特色原料") : YuanLiao() {
}


